package cn.edu.scau.cmi.xiaozhenlin.multipleton;

import java.util.ArrayList;

public class Marshal {
	private String name;
	// 多例数量
	private static final int N = 10;
	// 存放N个实例对象的容器
	private static ArrayList<Marshal> list = new ArrayList<Marshal>(N);

	// 私有构造方法 防止外界应用程序实例化
	private Marshal(String name) {
		this.name = name;
	}

	public static ArrayList<Marshal> getInstance(String name) {
		if (list.size() < N) {
			list.add(new Marshal(name));
			return list;
		} else {
			return list;
		}

	}

	public String getName() {
		return this.name;
	}
}
